package com.chengh.springboot.webservice.config;

import com.chengh.springboot.webservice.service.StudentService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

@Slf4j
@Configuration
@RequiredArgsConstructor
public class WebServiceConfiguration {

    private final StudentService studentService;

    private final SpringBus springBus;


    @Bean
    public Endpoint StudentServiceEndpoint() {
        log.info("服务发布开始");
        String path = "http://127.0.0.1:8081/wenservice/student";
        EndpointImpl endpoint = new EndpointImpl(springBus, studentService);
        endpoint.publish(path);
        log.info("服务发布成功");
        log.info("在线的wsdl: {}{}", path, "?wsdl");
        return endpoint;
    }

}
